package com.sunnada.edu.system.org.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.sunnada.edu.system.pub.dao.BaseDaoImpl;

@Repository
public class OrgDaoImpl extends BaseDaoImpl implements OrgDao {
	@Override
	public List<?> orgTree(HashMap<String, String> params) {
		return selectList("org_sqlmap.orgTree", params);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public int getOrgCots(HashMap<String, String> params) {
		List list = selectList("org_sqlmap.getOrgCots", params);
		if (list != null && list.size() > 0) {
			String cot = ((Map) list.get(0)).get("COT") + "";
			return Integer.valueOf(cot);
		}
		return 0;
	}

	@Override
	public List<?> findOrgs(HashMap<String, String> params) {
		return selectList("org_sqlmap.findOrgs", params);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Map getOrgByOrgcord(HashMap<String, String> params) {
		List list = selectList("org_sqlmap.getOrgByOrgcode", params);
		if (list != null && list.size() > 0) {
			return (Map) list.get(0);
		}
		return null;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public String orgTreebig(HashMap<String, String> params) {
		List list = selectList("org_sqlmap.orgTreebig", params);
		if (list != null && list.size() > 0) {
			String cot = ((Map) list.get(0)).get("ORG_CODE") + "";
			return cot;
		}
		return "0";
	}

	@Override
	public int orgAdd(HashMap<String, String> params) {
		return insert("org_sqlmap.orgAdd", params);
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Map getOrgByRecId(HashMap<String, String> params) {
		List list = selectList("org_sqlmap.getOrgByRecId", params);
		if (list != null && list.size() > 0) {
			return (Map) list.get(0);
		}
		return null;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public Map orgByOrgcode(HashMap<String, String> params) {
		List list = selectList("org_sqlmap.getOrgByOrgcode", params);
		if (list != null && list.size() > 0) {
			return (Map) list.get(0);
		}
		return null;
	}

	@Override
	public int orgUpdate(HashMap<String, String> params) {
		return update("org_sqlmap.orgUpdate", params);
	}

	@Override
	public int orgDel(HashMap<String, String> params) {
		return delete("org_sqlmap.orgDel", params);
	}

	@Override
	public int orgEnable(HashMap<String, String> params) {
		return update("org_sqlmap.orgEnable", params);
	}

	@Override
	public int orgDisable(HashMap<String, String> params) {
		return update("org_sqlmap.orgDisable", params);
	}

	@Override
	public int orgContrastAdd(HashMap<String, String> params) {
		return insert("org_sqlmap.orgContrastAdd", params);
	}

}
